# -*- coding: utf-8 -*-
# Author: xiantingDeng
# File: 15_类属性实例属性.py
# Time: 21:20

# class Tool(object):
#     def __init__(self, new_name):
#         self.name = new_name
#
#
# num = 0
# tool1 = Tool("铁锹")
# num+=1
# print(num)
# tool2 = Tool("工兵铲")
# num+=1
# print(num)
# tool3 = Tool("水桶")
# num+=1
# print(num)

class Tool(object):

    #类属性
    num = 0

    #方法
    def __init__(self, new_name):
        #实例属性
        self.name = new_name
        #对类属性+=1
        Tool.num += 1


tool1 = Tool("铁锹").num
tool2 = Tool("工兵铲")
tool3 = Tool("水桶")
print(Tool.num)

